

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/getreq")
public class getreq extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public getreq() throws ClassNotFoundException {
        super();
        Class.forName ("org.sqlite.JDBC");

    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			Connection conn = DriverManager.getConnection("jdbc:sqlite:cms.db");
			PreparedStatement preStatement = conn.prepareStatement("select roll, total ,installement,due from fee where req= \"1\";");
		    String s="<table width=\"400\" border=\"1\"><tr><th scope=\"col\">roll number</th><th scope=\"col\">total fee</th><th scope=\"col\">installements</th><th scope=\"col\">due date</th></tr>";
	        ResultSet res=preStatement.executeQuery();
		   while(res.next())
		   {
		    String roll=res.getString(1);
		    String total=res.getString(2);
		    String installement=res.getString(3);
		    String due=res.getString(4);
		    s=s+ "<tr><td id=\"roll\">"+ roll +"</td><td>"+ total +"</td><td>"+installement+"</td><td>"+due+"</td></tr>";
		   }
		   s=s+"<table>";
		    response.getWriter().println(s);
		    preStatement.close();
			conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}

	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

}
